var a = getApp();

Page({
  data: {
    page: 1,
    loadingBoo: !0,
    moreBoo: !0,
    proList:[
      {
        id:1,
        mainImage: '/assets/shop_images/head.png',
        title:123,
        num:20,
        price:20000
      }
    ]
  },
  getValue: function(a) {
    0 == a.detail.value.replace(/(^\s*)|(\s*$)/g, "").length && this.setData({
      searchFlag: !1
    }), this.setData({
      keyword: a.detail.value
    });
  },
  goSearch: function(a) {
    var t = this;
    if (t.setData({
        proFlag: !1,
        loadingBoo: !0,
        moreBoo: !0,
        proList: []
      }), 0 == t.data.keyword.replace(/(^\s*)|(\s*$)/g, "").length) return t.setData({
      page: 1
    }), void wx.showToast({
      title: "请输入搜索内容",
      icon: "none",
      duration: 1e3
    });
    // wx.showLoading({
    //   title: "加载中...",
    //   mask: !0
    // });
    var o = t.data.shopSearchList.indexOf(t.data.keyword); -
    1 != o ? (t.data.shopSearchList.splice(o, 1), t.data.shopSearchList.unshift(t.data.keyword)) : (t.data.shopSearchList.length >= 6 && t.data.shopSearchList.splice(t.data.shopSearchList.length - 1, 1),
        t.data.shopSearchList.unshift(t.data.keyword)), wx.setStorageSync("shopSearchList", t.data.shopSearchList),
      t.setData({
        shopSearchList: t.data.shopSearchList,
        searchFlag: !0,
        page: 1
      }), t.search();
  },
  search: function() {
    var t = this;
    // wx.request({
    //   url: a.globalData.httpOne + "mall/item/search",
    //   method: "POST",
    //   header: {
    //     "content-type": "application/x-www-form-urlencoded"
    //   },
    //   data: {
    //     keyword: t.data.keyword,
    //     page: t.data.page
    //   },
    //   success: function(a) {
    //     wx.hideLoading(), 200 == a.data.code && (a.data.data.length > 0 && null != a.data.data ? 1 == t.data.page ? t.setData({
    //       proList: a.data.data,
    //       loadingBoo: !0
    //     }) : (a.data.data.forEach(function(a) {
    //       t.data.proList.push(a);
    //     }), t.setData({
    //       proList: t.data.proList,
    //       loadingBoo: !0
    //     })) : 1 == t.data.page ? (wx.hideLoading(), t.setData({
    //       proFlag: !0,
    //       loadingBoo: !0
    //     })) : t.setData({
    //       loadingBoo: !0,
    //       moreBoo: !1
    //     }), t.setData({
    //       page: t.data.page + 1
    //     }));
    //   }
    // });
    let a = [
      {
        id: 1,
        mainImage: '/assets/shop_images/head.png',
        title: '感冒药',
        num: 20,
        price: 20000
      },
      {
        id: 1,
        mainImage: '/assets/shop_images/head.png',
        title: '感冒药',
        num: 20,
        price: 20000
      },
      {
        id: 1,
        mainImage: '/assets/shop_images/head.png',
        title: '感冒药',
        num: 20,
        price: 20000
      }
    ]
    t.setData({
      proList: a
    })
  },
  toSearch: function(a) {
    this.setData({
      keyword: a.target.dataset.text
    });
  },
  getMore: function() {
    this.data.moreBoo && this.data.loadingBoo && (this.setData({
      loadingBoo: !1
    }), this.search());
  },
  onLoad: function(a) {
    this.setData({
      shopSearchList: wx.getStorageSync("shopSearchList") || []
    });
  },
  onReady: function() {},
  onShow: function() {},
  onHide: function() {},
  onUnload: function() {},
  onPullDownRefresh: function() {},
  onReachBottom: function() {}
});